import { defineStore } from 'pinia'
import { reactive, ref } from 'vue'
import { UserInfo } from '@/assets/apis/UserDataType'

export const useUserStore = defineStore('userInfoStore', () => {
    const currentTheme = ref('dark')
    const userInfo = reactive(<UserInfo>{})
    const loginDialogVisible = ref(false)
    const isLogin = ref(false)
    return {currentTheme,userInfo,loginDialogVisible,isLogin}
  },
  {
    //开启持久化 = 》 localStorage
    persist: {
      key: 'userInfoStore',
      storage: localStorage,
      pick: ['currentTheme', 'userInfo', 'isLogin']
    }
  })
